package com.jojo.store.controller;

import com.jojo.store.entity.Product;
import com.jojo.store.service.ProductService;
import com.jojo.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/products")
public class ProductController extends BaseController{
    @Autowired
    private ProductService productService;
@RequestMapping("/hot_list")
    public JsonResult<List<Product>> hotAllPro(){
    List<Product> data = productService.findAllHotPro();
    return new JsonResult<>(OK,data);
}
@RequestMapping("{id}/details")
    public JsonResult<Product> getDetailsByid(@PathVariable("id")Integer id){
    Product data = productService.findByid(id);
    return new JsonResult<Product>(OK,data);
}

}
